import java.io.*;
import java.net.*;


public class EchoTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		String temp;
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		
		Socket socket = new Socket("www.thundermail.co.kr",7);
		
		BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
		
		PrintWriter pw = new PrintWriter(socket.getOutputStream(),true);
		
		System.out.println("\nInput Echo: ");
		while((temp = stdin.readLine()) != null){
			pw.println(temp);//소켓의 출력스트림으로 데이터 전송

			System.out.print("echo: " +br.readLine() +"\nInput Echo:"); //소켓의 입력스트림으로 데이터 읽어냄

		}
		br.close();
		pw.close();
		socket.close();

	}

}
